package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.ShowMachineEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;
@Deprecated
public class ShowMechanicsAdapter extends BaseRecycleAdapter<ShowMachineEntity> {

    private TextView price_view;
    private TextView tv_area;
    private TextView tv_time;

    public ShowMechanicsAdapter(Context context, List<ShowMachineEntity> datas) {
        super(context, R.layout.item_show_mechanics, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ShowMachineEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        price_view = holder.itemView.findViewById(R.id.price_view);
        tv_area = holder.itemView.findViewById(R.id.tv_area);
        tv_time = holder.itemView.findViewById(R.id.tv_time);
        //和price重复判断是为了兼容旧数据
        if (entity.getNegotiable()==0){
            price_view.setText(entity.getRentalPrice() + entity.getPriceUnit());
        }else {
            price_view.setText("面议");
        }
        tv_area.setText(entity.getCity() + " " + entity.getDistrict());
        try {
            tv_time.setText(DateUtils.stampToDay(entity.getUpdateTime()));
        }catch (Exception e){}
    }
}
